﻿@using GoodMan.Infrastructure.Entities.Entity;
@using GoodMan.Infrastructure.Entities.Enum;
@using GoodMan.Infrastructure.Entities.Contract;
@using GoodMan.Tool.Framework;
@{
    Layout = "~/Views/Shared/_Main.cshtml";
    Order order = ViewBag.Order == null ? new Order() : ViewBag.Order;
    var areacode = ViewBag.areaCode;
    decimal limitprice = ViewBag.limitprice == null ? 5 : ViewBag.limitprice;

    int totalinjifen =(int)(order.TotalPrice * GoodMan.Portal.Biz.SupportBiz.GetCostRank());
}
@section head
{
    <script type="text/javascript">
        $(document).ready(function () {
            $('#btnClearCart').click();
        });

        function clearCart() {
            $.post("/Shop/ClearShoppingCart", null, function (response) {
                $("#cart").html(response.split('^')[0]);
                $("#shoppingcartitem").html(response.split('^')[1]);
            });
        }
    </script>
}
<div class="container">
    <ul class="breadcrumb">
        <li><a href="../home/index">首页</a> <span class="divider">></span></li>
        <li class="active">订单支付</li>
    </ul>
    <form action="/shop/PayOrder" id="formSo" name="formso" method="post">
    <input type="hidden" name="orderId" id="orderId" value="@order.Id" />
    <input type="hidden" name="areacode" value="@areacode" />
    <div class="breadcrumb">
        <div>
            <span style="font-size: 15px;"><strong>支付信息</strong></span></div>
        <table class="table">
            <tr>
                <td style="width: 100px">
                    商品信息
                </td>
                <td>
                    @{
                        if (order.AreaCode == AreaCode.Snack)
                        {
                            if (order.ProductDescript.Contains("cateringList"))
                            {
                                OrderDetail detail = new OrderDetail().Find(c => c.OrderId == order.Id);

                                CateringSet catering = order.ProductDescript.ToObject<CateringSet>();
                                if (catering != null && catering.cateringList != null && catering.cateringList.Any())
                                {
                                    foreach (var cItem in catering.cateringList)
                                    {
                        <div>
                            @cItem.caterCategory&nbsp &nbsp;&nbsp;</div>
                        <div>
                            @{
                                        foreach (var ciItem in cItem.cateringInfoList)
                                        {
                                <span>菜名:<b><font color="#333399">@ciItem.caterName</font></b>&nbsp;&nbsp;价格:&yen;@ciItem.caterPrice&nbsp;
                                    &nbsp;份数:<font color="#ff0000">@ciItem.caterNumber</font></span>
                                        }
                            }
                        </div>
                                                       
                        <hr />
                                    }
                        <div>
                            <b>共计：<font color="#FF0000">@detail.Num</font>&nbsp;&nbsp;份</b></div>
                                }
                            }
                            else
                            {
                        @Html.Raw(order.ProductDescript)
                            }
                        }
                        else
                        {
                        @order.ProductDescript
                        }
                    }
                </td>
            </tr>
            <tr><td>备注：</td><td>@order.Remark</td></tr>
            
            <tr>
                <td>
                    配送信息
                </td>
                <td>
                    @order.AssemblingInfo
                </td>
            </tr>
            @{
                if (areacode == 3)
                {
                <tr>
                    <td>
                        所需积分
                    </td>
                    <td style="font-size: 19px; color: #DC143C; font-weight: bold;">
                        @totalinjifen 分
                    </td>
                </tr>
                }
                else
                {
                <tr>
                    <td>
                        支付金额
                    </td>
                    <td style="font-size: 19px; color: #DC143C; font-weight: bold;">
                        &yen; @order.TotalPrice
                       @{ if (order.TotalPrice < limitprice)
                          { <span style="font-size: 14px;color:red;">您购物不足 @limitprice 元，请自行前往楼栋售货员处提货并付款。</span>
                          }
                        }
                    </td>
                </tr>
                }
                <tr>
                    <td>
                        支付方式
                    </td>
                    <td>
                        
                        @{ 
                    if (areacode == 3)
                    {
                        <span><input type="radio" id="payTypeChange"  name="payType" value="3" checked="checked"/>积分兑换</span>
                    }
                    else
                    {
                        if (order.TotalPrice < limitprice)
                        {
                                <span><input type="radio" id="payTypeCash" name="payType" value="2" checked="checked" />上门取货</span>
                        }
                        else
                        {
                                 <span><input type="radio" id="payTypeCash" name="payType" value="2" checked="checked" />货到付款</span>
                        }
                    }
                         }
                            &nbsp; &nbsp;@*<span><input
                                type="radio" id="payTypeOnline" disabled="disabled" name="payType" value="1" />在线支付</span>*@
                                
                    </td>
                </tr>
                }
            
            <tr>
                <td>
                    &nbsp;
                </td>
                <td>
                    <input type="submit" class="btn btn-danger" style="margin-top: 10px; font-size: 17px;"
                        value="确定" />
                </td>
            </tr>
        </table>
        <input type="button" id="btnClearCart" onclick="clearCart()" style="display: none" />
    </div>
    </form>
</div>
@section tail{
    <script type="text/javascript">
        $("input:submit").each(function () {
            var srcclick = $(this).attr("onclick");
            if (typeof (srcclick) == "function") {
                $(this).click(function () {
                    if (srcclick()) {
                        setdisabled(this);
                        return true;
                    }
                    return false;
                });
            }
        });
        function setdisabled(obj) {
            setTimeout(function () { obj.disabled = true; }, 100);
        }
    
    </script>
}
